﻿using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

public class SampleObjectMananger
{
    private static string resPath = "Assets/ResourcesAssets/World/prefabs/city/city_test.prefab";
    private static Dictionary<int, GameObject> goDic = new Dictionary<int, GameObject>();

    public static void CreateSampleObject(int id, Vector2 pos)
    {
#if UNITY_EDITOR
        var asset = AssetDatabase.LoadAssetAtPath<GameObject>(resPath);
        GameObject go = GameObject.Instantiate(asset) as GameObject;
        go.transform.position = new Vector3(pos.x, 1, pos.y);
        goDic.Add(id, go);
#endif
    }

    public static void RemoveSampleObject(int id)
    {
        GameObject go;
        if (goDic.TryGetValue(id, out go))
        {
            GameObject.DestroyImmediate(go);
            goDic.Remove(id);
        }
    }
}